#include "global.h"

bool operator==(const MotionKeyFrame& frame1, const MotionKeyFrame& frame2) {
    if (frame1.timestamp == frame2.timestamp) {
        if (frame1.jointValues.size() == frame2.jointValues.size()) {
            return frame1.jointValues == frame2.jointValues;
        } else {
            return false;
        }
    } else {
        return false;
    }
}

#ifdef KINECT
MotionKeyFrame troyStateToKeyFrame(kinect::TroyState* troy) {
   MotionKeyFrame keyFrame;
   keyFrame.timestamp = -1;
   foreach (kinect::TroyState::Joint joint, kinect::TroyState::allJoints()) {
       if (troy->hasJoint(joint)) {
           keyFrame.jointValues.append(QPair<int, float>(kinect::TroyState::jointId(joint), RADIANS_TO_DEGREES(troy->getJoint(joint))));
       }
   }
   return keyFrame;
}

kinect::TroyState* keyFrameToTroyState(MotionKeyFrame frame, QObject* parent) {
    kinect::TroyState* troy = new kinect::TroyState(parent);
    foreach (JointValue joint, frame.jointValues) {
        troy->setJoint(kinect::TroyState::jointId(joint.first), DEGREES_TO_RADIANS(joint.second));
    }
    return troy;
}
#endif
